package com.hpsk.webSocket.model.ai.service.impl;

import com.hpsk.webSocket.model.ai.dto.BizAiMessageContentParamDto;
import com.hpsk.webSocket.model.ai.entity.BizAiMessageContent;
import com.hpsk.webSocket.model.ai.dao.BizAiMessageContentMapper;
import com.hpsk.webSocket.model.ai.service.IBizAiMessageContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.linpeilie.Converter;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 消息内容 服务实现类
 * </p>
 *
 * @author huangwang
 * @since 2025-05-20
 */
@Service
@AllArgsConstructor(onConstructor_ = @__(@Autowired))
public class BizAiMessageContentServiceImpl extends ServiceImpl<BizAiMessageContentMapper, BizAiMessageContent> implements IBizAiMessageContentService {

    private final Converter converter;
    @Override
    public BizAiMessageContent add(BizAiMessageContentParamDto paramDto, String type) {
        BizAiMessageContent convert = converter.convert(paramDto, BizAiMessageContent.class);
        if(convert.getMessageId() == null){
            throw new RuntimeException("消息体id不能为空");
        }
        convert.setType(type);
        save(convert);
        return convert;
    }
}
